package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.Article;
import org.example.pojo.Client;

import java.util.List;

@Mapper
public interface ClientMapper {
    List<Client> list(Integer userId, String state);

    @Insert("insert into client(create_user,name,contact_person,contact_phone,email,address,state,contract_start,contract_end,create_time,update_time)" +
            " values (#{createUser},#{name},#{contactPerson},#{contactPhone},#{email},#{address},#{state},#{contractStart},#{contractEnd},#{createTime},#{updateTime})")
    void add(Client client);

    @Update("update client set name=#{name}, contact_person=#{contactPerson}, contact_phone=#{contactPhone}, email=#{email}, address=#{address}, state=#{state}, contract_start=#{contractStart}, contract_end=#{contractEnd}, update_time=#{updateTime} where id=#{id}")
    void update(Client client);

    @Delete("delete from client where id=#{id}")
    void delete(Integer id);

    @Select("select * from client where id=#{id}")
    Client getById(Integer id);

    @Select("select * from client where create_user=#{id}")
    List<Client> getAll(Integer id);

    @Select("select * from client where name=#{name}")
    List<Client> getClientByName(String name);
}
